<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OSI模型中TCP、HTTP和FTP协议解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=NotoSans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .noto-serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-8px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4em;
            line-height: 0.65;
            margin: 0.1em 0.15em 0 0;
            color: #4f46e5;
            font-weight: 700;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 lg:px-0">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col items-center justify-center text-center">
                <div class="flex items-center mb-4">
                    <div class="w-3 h-3 bg-indigo-300 rounded-full mr-2"></div>
                    <div class="w-3 h-3 bg-indigo-400 rounded-full mr-2"></div>
                    <div class="w-3 h-3 bg-indigo-500 rounded-full"></div>
                </div>
                <h1 class="text-4xl md:text-5xl font-bold mb-4 noto-serif">OSI模型中的核心协议解析</h1>
                <p class="text-xl md:text-2xl opacity-90 mb-8 max-w-3xl">探索TCP、HTTP和FTP在网络通信中的关键角色与层级关系</p>
                <a href="#content" class="flex items-center justify-center w-12 h-12 rounded-full bg-white bg-opacity-20 hover:bg-opacity-30 transition-all">
                    <i class="fas fa-chevron-down text-white"></i>
                </a>
            </div>
        </div>
    </section>

    <!-- OSI Model Visualization -->
    <section class="py-16 px-4 lg:px-0 bg-white">
        <div class="container mx-auto max-w-5xl">
            <h2 class="text-3xl font-bold mb-8 text-center noto-serif">OSI七层模型可视化</h2>
            <div class="bg-gray-50 p-6 rounded-xl shadow-sm">
                <div class="mermaid">
                    graph TD
                        A[应用层<br>HTTP/FTP] --> B[表示层]
                        B --> C[会话层]
                        C --> D[传输层<br>TCP]
                        D --> E[网络层]
                        E --> F[数据链路层]
                        F --> G[物理层]
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main id="content" class="py-12 px-4 lg:px-0">
        <div class="container mx-auto max-w-3xl">
            <!-- TCP Section -->
            <article class="mb-20">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 rounded-lg bg-indigo-100 text-indigo-600 flex items-center justify-center mr-4">
                        <i class="fas fa-shield-alt text-2xl"></i>
                    </div>
                    <div>
                        <span class="inline-block px-3 py-1 text-xs font-semibold bg-indigo-100 text-indigo-800 rounded-full mb-1">传输层</span>
                        <h2 class="text-2xl md:text-3xl font-bold noto-serif">TCP协议</h2>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <div class="mb-6">
                            <img src="https://images.unsplash.com/photo-1454165804606-c3d57bc86b40?ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80" alt="TCP协议示意图" class="w-full h-64 object-cover rounded-lg">
                        </div>
                        <div class="prose max-w-none">
                            <p class="drop-cap">传输控制协议（TCP）位于OSI模型的第四层——传输层。传输层的主要职责是为端到端的数据传输提供可靠的通信服务，而TCP正是用于实现这一目标的核心协议之一。</p>
                            
                            <p>TCP通过分段（Segmentation）将数据拆分成更小的片段，确保数据的有序传输和完整接收。TCP提供了诸如流量控制（Flow Control）、拥塞控制（Congestion Control）和错误检测（Error Detection）等功能。这些机制确保了数据包能够从发送方正确传送到接收方，即使在网络不稳定的情况下，也能保证数据的完整性和顺序性。</p>
                            
                            <div class="bg-gray-50 p-4 rounded-lg my-6 border-l-4 border-indigo-500">
                                <div class="flex">
                                    <div class="flex-shrink-0 text-indigo-500">
                                        <i class="fas fa-truck"></i>
                                    </div>
                                    <div class="ml-3">
                                        <p class="text-sm text-gray-600">
                                            <strong>类比理解：</strong> 可以将TCP想象成一个负责快递包裹的可靠物流公司。它不仅将包裹从一个地点安全送到另一个地点，还确保所有包裹按顺序到达，任何丢失的包裹都会被重新发送。
                                        </p>
                                    </div>
                                </div>
                            </div>
                            
                            <h3 class="text-xl font-semibold mt-8 mb-4 noto-serif">TCP核心特性</h3>
                            <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
                                <div class="flex items-start p-4 bg-indigo-50 rounded-lg">
                                    <div class="flex-shrink-0 mt-1 mr-3 text-indigo-600">
                                        <i class="fas fa-check-circle"></i>
                                    </div>
                                    <div>
                                        <h4 class="font-medium text-gray-900">可靠传输</h4>
                                        <p class="mt-1 text-sm text-gray-600">通过确认机制和重传策略确保数据准确送达</p>
                                    </div>
                                </div>
                                <div class="flex items-start p-4 bg-indigo-50 rounded-lg">
                                    <div class="flex-shrink-0 mt-1 mr-3 text-indigo-600">
                                        <i class="fas fa-exchange-alt"></i>
                                    </div>
                                    <div>
                                        <h4 class="font-medium text-gray-900">流量控制</h4>
                                        <p class="mt-1 text-sm text-gray-600">防止发送方过快地发送数据超过接收方处理能力</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </article>
            
            <!-- HTTP Section -->
            <article class="mb-20">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 rounded-lg bg-blue-100 text-blue-600 flex items-center justify-center mr-4">
                        <i class="fas fa-globe text-2xl"></i>
                    </div>
                    <div>
                        <span class="inline-block px-3 py-1 text-xs font-semibold bg-blue-100 text-blue-800 rounded-full mb-1">应用层</span>
                        <h2 class="text-2xl md:text-3xl font-bold noto-serif">HTTP协议</h2>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <div class="mb-6">
                            <img src="https://images.unsplash.com/photo-1517430816045-df4b7de11d1d?ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80" alt="HTTP协议示意图" class="w-full h-64 object-cover rounded-lg">
                        </div>
                        <div class="prose max-w-none">
                            <p class="drop-cap">超文本传输协议（HTTP）位于OSI模型的第七层——应用层。应用层负责直接为用户提供网络服务和应用程序功能。HTTP是一种用于传输超文本的协议，是万维网上数据交换的基础。</p>
                            
                            <p>它定义了客户端（如Web浏览器）和服务器之间如何请求和响应数据。HTTP是无状态的（Stateless），意味着每次请求都是独立的，不会记住之前的请求状态。HTTP通常用于请求和传输网页、图片、视频等互联网内容。</p>
                            
                            <div class="bg-blue-50 p-4 rounded-lg my-6 border-l-4 border-blue-500">
                                <div class="flex">
                                    <div class="flex-shrink-0 text-blue-500">
                                        <i class="fas fa-utensils"></i>
                                    </div>
                                    <div class="ml-3">
                                        <p class="text-sm text-gray-600">
                                            <strong>类比理解：</strong> 可以将HTTP看作是一个简单的餐厅服务员，它只负责传递菜单和订单，不会记住客户之前的点单内容。每次点单（请求）和上菜（响应）都是新的过程，没有"记忆"。
                                        </p>
                                    </div>
                                </div>
                            </div>
                            
                            <h3 class="text-xl font-semibold mt-8 mb-4 noto-serif">HTTP工作原理</h3>
                            <div class="mermaid mb-6">
                                sequenceDiagram
                                    participant Client
                                    participant Server
                                    Client->>Server: HTTP Request
                                    Server->>Client: HTTP Response
                                    Note over Client,Server: 每个请求/响应都是独立的
                            </div>
                        </div>
                    </div>
                </div>
            </article>
            
            <!-- FTP Section -->
            <article class="mb-20">
                <div class="flex items-center mb-6">
                    <div class="w-12 h-12 rounded-lg bg-green-100 text-green-600 flex items-center justify-center mr-4">
                        <i class="fas fa-file-upload text-2xl"></i>
                    </div>
                    <div>
                        <span class="inline-block px-3 py-1 text-xs font-semibold bg-green-100 text-green-800 rounded-full mb-1">应用层</span>
                        <h2 class="text-2xl md:text-3xl font-bold noto-serif">FTP协议</h2>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <div class="mb-6">
                            <img src="https://images.unsplash.com/photo-1554224155-6726b3ff858f?ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&q=80" alt="FTP协议示意图" class="w-full h-64 object-cover rounded-lg">
                        </div>
                        <div class="prose max-w-none">
                            <p class="drop-cap">文件传输协议（FTP）同样位于OSI模型的第七层——应用层。FTP是一种用于在客户端和服务器之间传输文件的标准协议。它支持双向文件传输，并允许用户进行文件的上传和下载操作。</p>
                            
                            <p>FTP还支持用户身份验证，可以通过用户名和密码来控制对文件的访问权限。由于它工作在应用层，FTP依赖于传输层（通常是TCP）来提供可靠的数据传输服务。</p>
                            
                            <div class="bg-green-50 p-4 rounded-lg my-6 border-l-4 border-green-500">
                                <div class="flex">
                                    <div class="flex-shrink-0 text-green-500">
                                        <i class="fas fa-truck-moving"></i>
                                    </div>
                                    <div class="ml-3">
                                        <p class="text-sm text-gray-600">
                                            <strong>类比理解：</strong> FTP类似于一个专门的邮递员服务，它不仅能够发送和接收包裹（文件），而且允许寄件人和收件人根据需要定制传递的时间和顺序。
                                        </p>
                                    </div>
                                </div>
                            </div>
                            
                            <h3 class="text-xl font-semibold mt-8 mb-4 noto-serif">FTP主要特点</h3>
                            <ul class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1 mr-3 text-green-500">
                                        <i class="fas fa-check"></i>
                                    </div>
                                    <div>
                                        <h4 class="font-medium text-gray-900">双向传输</h4>
                                        <p class="text-sm text-gray-600">支持文件上传和下载</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1 mr-3 text-green-500">
                                        <i class="fas fa-check"></i>
                                    </div>
                                    <div>
                                        <h4 class="font-medium text-gray-900">身份验证</h4>
                                        <p class="text-sm text-gray-600">通过用户名和密码控制访问</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1 mr-3 text-green-500">
                                        <i class="fas fa-check"></i>
                                    </div>
                                    <div>
                                        <h4 class="font-medium text-gray-900">可靠性</h4>
                                        <p class="text-sm text-gray-600">基于TCP确保传输可靠</p>
                                    </div>
                                </li>
                                <li class="flex items-start">
                                    <div class="flex-shrink-0 mt-1 mr-3 text-green-500">
                                        <i class="fas fa-check"></i>
                                    </div>
                                    <div>
                                        <h4 class="font-medium text-gray-900">目录操作</h4>
                                        <p class="text-sm text-gray-600">支持目录创建、删除等操作</p>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </article>
            
            <!-- Summary Section -->
            <section class="mb-20">
                <h2 class="text-3xl font-bold mb-8 text-center noto-serif">协议对比总结</h2>
                <div class="bg-white rounded-xl shadow-md overflow-hidden">
                    <div class="p-6">
                        <div class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead class="bg-gray-50">
                                    <tr>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">协议</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">OSI层级</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">主要功能</th>
                                        <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">特点</th>
                                    </tr>
                                </thead>
                                <tbody class="bg-white divide-y divide-gray-200">
                                    <tr class="hover:bg-gray-50">
                                        <td class="px-6 py-4 whitespace-nowrap font-medium text-indigo-600">TCP</td>
                                        <td class="px-6 py-4 whitespace-nowrap">传输层 (第4层)</td>
                                        <td class="px-6 py-4">提供可靠的端到端数据传输</td>
                                        <td class="px-6 py-4">面向连接、可靠传输、流量控制、拥塞控制</td>
                                    </tr>
                                    <tr class="hover:bg-gray-50">
                                        <td class="px-6 py-4 whitespace-nowrap font-medium text-blue-600">HTTP</td>
                                        <td class="px-6 py-4 whitespace-nowrap">应用层 (第7层)</td>
                                        <td class="px-6 py-4">超文本传输</td>
                                        <td class="px-6 py-4">无状态、请求-响应模型、基于TCP</td>
                                    </tr>
                                    <tr class="hover:bg-gray-50">
                                        <td class="px-6 py-4 whitespace-nowrap font-medium text-green-600">FTP</td>
                                        <td class="px-6 py-4 whitespace-nowrap">应用层 (第7层)</td>
                                        <td class="px-6 py-4">文件传输</td>
                                        <td class="px-6 py-4">双向传输、身份验证、基于TCP</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col items-center">
                <div class="text-xl font-medium mb-2">技术小馆</div>
                <a href="http://www.yuque.com/jtostring" class="text-gray-400 hover:text-white transition-colors duration-200">
                    http://www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>